
* Replication dofile for "The Value of Information in Competitive Markets: Evidence from Small and Medium Size Enterprises"

* Data is proprietary and owned from the bank.
* The authors of the paper do not own the data. They worked with the data as long as they had access to it and always inside the facilities of the bank.
* Authors obtained data directly from the Data Anlytics department of the bank.
* The source data used to create dependent variables and the list of adopting establishments are confidential information.
* To the best of our knowledge, data can be currently obtained from a company called GeoBlink. Geoblink is currently the bank's partner in commercializing the data and keeping the establishments' confidentiality. This same firm works with other data providers as well.
* Researchers interested should contact GeoBlink and inquire for the cost of purchasing or licensing data similar to the data used in our analysis.
* The authors do not have any conflict of interest or relationship with either the bank or GeoBlink.
		
		
		***********************************************************************************
		* TABLE 1A: ADOPTERS PER ZIPCODE and SECTOR DYADS
		***********************************************************************************								 

			use "Info Adopters.dta"

			preserve

			bys Zone Sector: gen N=_N

			collapse N,by(Zone Sector)

			tab N

			restore

		***********************************************************************************
		* TABLE 1B: TIMING OF ADOPTION
		***********************************************************************************								 

			tab Fuc_quarter_created

			clear
		
		***********************************************************************************
		* TABLE 2A: SUMMARY STATISTICS II
		***********************************************************************************								 
		
			use "Short_Final_Main.dta"
				
		* Responses on sophistication
			preserve
			keep if Adopter==1 & temp_est==1
			gen Sophistication= (analytical_user + marketing_user + digital_user)/3
			br merchant_fuc Sophistication 
			gen temp=(Sophistication!=.)
			sum temp
			sum Sophistication if Sophistication!=.,d
			restore		
			
		* Competition
			cap drop temp*
			bys merchant_postal_code merchant_category_id Date: gen temp_N=_N
			bys merchant_fuc: egen temp_Competition_estabs=mean(temp_N)
			replace temp_Competition_estabs=temp_Competition_estabs-1
			bys merchant_fuc: gen temp_first=_n
			sum temp_Competition_estabs if temp_first==1,d
			sum temp_Competition_estabs if Adopter==1 & temp_first==1,d
			count if Adopter==1 & temp_first==1
	
		* Statistics of basic variables
			sum TotalAmount,d
			sum Transactions,d
			sum AverageAmount,d
			sum Customers,d
			gen AverageCustomer= TotalAmount/Customers
			sum AverageCustomer,d
		
		* Statistics of basic variables for adopters
		
			sum TotalAmount if Adopter==1,  
			sum Transactions if Adopter==1,  
			sum AverageAmount if Adopter==1, 
			sum Customers if Adopter==1, 
			sum AverageCustomer if Adopter==1, 
		
		
		***********************************************************************************
		* TABLE 2B: SUMMARY STATISTICS II
		***********************************************************************************								 
			
			drop Sophistication
			gen Sophistication= (analytical_user + marketing_user + digital_user)/3
			bys merchant_fuc: gen temp_1=_n==1
			
			gen temp_quarter_pre=1 if Adopter==1 & Adoption==0   
			gen temp_amount_quater_pre= temp_quarter_pre*TotalAmount
			bys merchant_fuc: egen temp_mean_quarter_pre=mean(temp_amount_quater_pre)
			bys merchant_fuc: gen temp_first=(_n==1)
							
			egen temp_group=group(merchant_category_id)  
			gen temp_threshold=.
			levelsof temp_group, local(levels) 
			foreach l of local levels { 
				sum temp_mean_quarter_pre if temp_group==`l' & temp_first==1 & Adopter==1,d
				local temp_t=r(p50)
				replace temp_threshold=`temp_t' if temp_group==`l'
				}
			
			gen temp_Big_size= (temp_mean_quarter_pre>=temp_threshold & Adopter==1)
			gen temp_Small_size= (temp_mean_quarter_pre<temp_threshold & Adopter==1)
						
			bys merchant_postal_code merchant_category_id Date: gen temp_Competition_estabs=_N
			sum temp_Competition_estabs if  Adopter==1,d  
			egen temp_thresholdN = pctile(temp_Competition_estabs) if Adoption==1 & Adopter==1, p(50)

			gen temp_Big= (temp_Competition_estabs>=temp_thresholdN & Adopter==1)
			gen temp_Small= (temp_Competition_estabs<temp_thresholdN & Adopter==1)
			
			keep if Adopter==1
			collapse  TotalAmount temp_Big_size temp_Small_size temp_Big temp_Small Sophistication temp_Competition_estabs temp_mean_quarter_pre,by(merchant_fuc)
			
			gen answersoph=1
			replace answersoph=0 if Sophistication==.

			ttest TotalAmount ,by(answersoph)
			ttest temp_Big_size ,by(answersoph)
			ttest temp_Small_size,by(answersoph)
			ttest temp_Big ,by(answersoph)
			ttest temp_Small ,by(answersoph)
			ttest temp_Competition_estabs ,by(answersoph)
			ttest temp_mean_quarter_pre,by(answersoph)
			
			clear
		
									
		***********************************************************************************
		* TABLE 3: MAIN RESULTS
		***********************************************************************************								 
				
			use "Short_Final_Main.dta"
				
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
				
		* 1. BASELINE				
			reghdfe D.(Log_TotalAmount Adoption) D.Age_*	, absorb($Controls) vce(cluster merchant_fuc) 
						

		* 2. ADOPTION IN SUBSEQUENT YEARS
			sort  merchant_fuc Date
				
			gen Adoption_1=Adoption
			replace Adoption_1=0 if Adoption==1 & Adoption[_n-1]==0 & merchant_fuc==merchant_fuc[_n-1]
			
			gen Adoption_2=Adoption_1
			replace Adoption_2=0 if Adoption_1==1 & Adoption_1[_n-1]==0 & merchant_fuc==merchant_fuc[_n-1]
			
			gen Adoption_3=Adoption_2
			replace Adoption_3=0 if Adoption_2==1 & Adoption_2[_n-1]==0 & merchant_fuc==merchant_fuc[_n-1]
				
			gen Adoption_4=Adoption_3
			replace Adoption_4=0 if Adoption_3==1 & Adoption_3[_n-1]==0 & merchant_fuc==merchant_fuc[_n-1]
			
			gen Adoption_5=Adoption_4
			replace Adoption_5=0 if Adoption_4==1 & Adoption_4[_n-1]==0 & merchant_fuc==merchant_fuc[_n-1]
				
			gen Adoption_6=Adoption_5
			replace Adoption_6=0 if Adoption_5==1 & Adoption_5[_n-1]==0 & merchant_fuc==merchant_fuc[_n-1]
				
			gen Adoption_7=Adoption_6
			replace Adoption_7=0 if Adoption_6==1 & Adoption_6[_n-1]==0 & merchant_fuc==merchant_fuc[_n-1]
				
					
			reghdfe D.(Log_TotalAmount Adoption Adoption_1 Adoption_2 Adoption_3 Adoption_4 Adoption_5 Adoption_6 Adoption_7) D.Age_*, absorb($Controls) vce(cluster merchant_fuc)	
								
			drop Adoption_1 Adoption_2 Adoption_3 Adoption_4 Adoption_5 Adoption_6 Adoption_7 
				
		* 3. FALSIFICATION EXERCISE
			global Regressors="Adoption_falsification"
				
			reghdfe D.(Log_TotalAmount Adoption_falsification) D.Age_*	, absorb($Controls) vce(cluster merchant_fuc)

		* 4. CF
			cap drop res
			reghdfe D.Adoption IV_NonAcc_real_2 D.Age_*	, absorb($Controls) vce(cluster merchant_fuc) residuals(res)
						
			reghdfe D.(Log_TotalAmount Adoption) res D.Age_*, absorb($Controls) vce(cluster  merchant_fuc) 
			test res  
							
		* 5. IV one stage

			ivreghdfe D.Log_TotalAmount (D.Adoption = IV_NonAcc_real_2) D.Age_*,	absorb($Controls) cluster(merchant_fuc)
				
				
		* 6. OLS TRENDS FOR ESTABLISHMENTS IN DIFFERENT BANK BRANCHES	
			sort Date
			bys Date: gen temp_1 =(_n==1)
			gen temp_2=sum(temp_1)
			gen temp_3=temp_2^2
			br Date temp_1 temp_2
				
			xtset merchant_fuc Date	

			reghdfe D.Log_TotalAmount D.Adoption D.Age_* , absorb($Controls i.tx_merchant_branch#c.temp_2) vce(cluster merchant_fuc) 
						
		* 7. IV 1st STAGE TRENDS FOR ESTABLISHMENTS IN DIFFERENT BANK BRANCHES

			reghdfe D.Adoption IV_NonAcc_real_2 D.Age_* , absorb($Controls i.tx_merchant_branch#c.temp_2) vce(cluster merchant_fuc) 
				
		* 8. IV 2nd STAGE TRENDS FOR ESTABLISHMENTS IN DIFFERENT BANK BRANCHES

			ivreghdfe D.Log_TotalAmount (D.Adoption = IV_NonAcc_real_2) D.Age_* ,	absorb($Controls i.tx_merchant_branch#c.temp_2) cluster(merchant_fuc)   
				
			drop temp_*
				
				  
		***********************************************************************************
		* FIGURE 4: HETEROGENEOUS EFFECTS 
		***********************************************************************************
				
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
					
		* HETEROGENEOUS EFFECTS BY SECTOR
				
			preserve
				
			forval x=101(1)118{  
				gen Adoption_`x'=Adoption*(Sector==`x')
				}
					
			reghdfe D.Log_TotalAmount D.Adoption_1* D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
					
			matrix coef=e(b)'  
			matrix list coef
			svmat coef, names(coef) 
					
			keep coef1
			drop if coef1==.
			gen n=_n
			gsort -n
			drop if _n<=5
			drop if coef1==0  
					
			cd "$path"
			kdensity coef1, saving(sector_kernel, replace) title(Sector-level estimates) xtitle(Coeff estimates) xlab(-1(0.25)1)  
				
			restore
					
		* HETEROGENEOUS EFFECTS BY subSECTOR
				
			preserve
				
			forval x=1(1)77{
				gen Adoption_`x'=Adoption*(merchant_sub_category_id==`x')
				}
					
			drop Adoption_falsification 
			reghdfe D.Log_TotalAmount D.Adoption_* 	, absorb($Controls) vce(cluster merchant_fuc)
				
			matrix coef1=e(b)'  
			matrix list coef1
			svmat coef1, names(coef) 
					
			keep coef1
			drop if coef1==.
			gen n=_n
			gsort -n
			drop if _n<=5 
			drop if coef1==0  
										
			cd "$path"
			kdensity coef1, saving(sub_sector_kernel, replace)  title(Subsector-level estimates) xtitle(Coeff estimates) xlab(-1(0.25)1)

			restore
				
		* HETEROGENEOUS EFFECTS BY REGION
				
			preserve
				
			forval x=1(1)52{
				gen Adoption_`x'=Adoption*(merchant_region==`x')
				}
					
			drop Adoption_falsification 
					
			reghdfe D.Log_TotalAmount D.Adoption_* , absorb($Controls) vce(cluster merchant_fuc)
				
			matrix coef=e(b)'   
			matrix list coef
			svmat coef, names(coef) 
					
			keep coef1
			drop if coef1==.
			gen n=_n
			gsort -n
			drop if _n<=5 
			drop if coef1==0  
					
			ren n subregion_id
			merge 1:1 subregion_id using "$path/Description_subregion.dta"
			keep if _merge==3
					
			cd "$path"
			kdensity coef1, saving(region_kernel, replace)  title(Region-level estimates) xtitle(Coeff estimates) xlab(-1(0.25)1)
					
			restore
				
			cd "$path"
			gr combine sector_kernel.gph sub_sector_kernel.gph region_kernel.gph,   ///
			note("" "") ///
			saving(Combine_kernel_densities, replace)
				

		***********************************************************************************
		* TABLA 4A: HETEROGENEOUS EFFECTS I
		***********************************************************************************	
		
		* 1. DIFFERENCES IN SOPHISTICATION
			
			cap drop temp*
			drop Sophistication
			gen Sophistication= (analytical_user + marketing_user + digital_user)/3
			bys merchant_fuc: gen temp_1=_n==1
			replace temp_1=temp_1*(Adopter==1)*(Sophistication!=.)
			sum Sophistication if temp_1==1,d
			local temp_2=r(p50)
			dis "`temp_2'"
			gen High_soph=(Sophistication>=`temp_2' & Sophistication!=.)  
			gen Low_soph=(Sophistication<`temp_2' & Sophistication!=.) 
			
			gen Adoption_high_soph=Adoption*High_soph
			gen Adoption_low_soph=Adoption*(High_soph==0)
			gen Adopter_high_soph=Adopter*High_soph
			gen Adopter_low_soph=Adopter*(High_soph==0)
			drop temp_*	
			
			label var Adoption_high_soph "Adop high soph"
			label var Adoption_low_soph "Adop low soph"
			
			gen sample=1
			replace sample=0 if Adopter==1 & Sophistication==.
	
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
			
		
			reghdfe D.(Log_TotalAmount Adoption_high_soph Adoption_low_soph) D.Age_*  if sample==1 , absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_high_soph=D.Adoption_low_soph
			
			reghdfe D.Adoption IV_NonAcc_real_2 D.Age_* , absorb($Controls) vce(cluster merchant_fuc) residuals(res)
			
			reghdfe D.(Log_TotalAmount Adoption_high_soph Adoption_low_soph) res D.Age_* if sample==1 , absorb($Controls) vce(cluster merchant_fuc)
			test res
			test D.Adoption_high_soph=D.Adoption_low_soph
				
		
		* 2. DIFFERENCES IN SIZE
			
			gen temp_quarter_pre=1 if Adopter==1 & Adoption==0    
			gen temp_amount_quater_pre= temp_quarter_pre*TotalAmount
			bys merchant_fuc: egen temp_mean_quarter_pre=mean(temp_amount_quater_pre)
			bys merchant_fuc: gen temp_first=(_n==1)
							
			egen temp_group=group(merchant_category_id)  
			gen temp_threshold=.
			levelsof temp_group, local(levels) 
			foreach l of local levels { 
				sum temp_mean_quarter_pre if temp_group==`l' & temp_first==1 & Adopter==1,d
				local temp_t=r(p50)
				replace temp_threshold=`temp_t' if temp_group==`l'
				}
			
			gen temp_Big_size= (temp_mean_quarter_pre>=temp_threshold & Adopter==1)
			gen temp_Small_size= (temp_mean_quarter_pre<temp_threshold & Adopter==1)
			
			gen Adoption_BigSize=Adoption*(temp_Big_size==1)
			gen Adoption_SmallSize=Adoption*(temp_Small_size==1)
			drop temp_*
			
			label var Adoption_BigSize "Adop Large size"
			label var Adoption_SmallSize "Adop Small size"
	
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
				
			reghdfe D.(Log_TotalAmount Adoption_BigSize Adoption_SmallSize) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_BigSize = D.Adoption_SmallSize
			
			reghdfe D.(Log_TotalAmount Adoption_BigSize Adoption_SmallSize) res D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test res
			test D.Adoption_BigSize = D.Adoption_SmallSize

			
		* 3. DIFFERENCES IN BUSINESS DENSITY

			bys merchant_postal_code merchant_category_id Date: gen temp_Competition_estabs=_N
			sum temp_Competition_estabs if  Adopter==1,d  
			egen temp_threshold = pctile(temp_Competition_estabs) if Adoption==1 & Adopter==1, p(50)

			gen temp_Big= (temp_Competition_estabs>=temp_threshold & Adopter==1)
			gen temp_Small= (temp_Competition_estabs<temp_threshold & Adopter==1)
			
			gen Adoption_High_Comp=Adoption*(temp_Big==1)  
			gen Adoption_Low_Comp=Adoption*(temp_Small==1)
			drop temp_* 
			
			label var Adoption_High_Comp "Adop high comp sect-area"
			label var Adoption_Low_Comp "Adop low comp sect-area"
			
	
			xtset merchant_fuc Date
			
			reghdfe D.(Log_TotalAmount Adoption_High_Comp Adoption_Low_Comp) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_High_Comp = D.Adoption_Low_Comp

			reghdfe D.(Log_TotalAmount Adoption_High_Comp Adoption_Low_Comp ) res D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test res
			test D.Adoption_High_Comp = D.Adoption_Low_Comp

			
		* 4. MULTIESTABLISHMENT FIRMS
			
			bys merchant_fuc: gen temp_est=_n==1
			bys account: egen temp_multiestab=sum(temp_est)
			bys account: gen temp_account=_n==1
			tab temp_multiestab if temp_account==1
			
			gen Adoption_multi_estab=Adoption*(temp_multiestab>1)
			gen Adoption_single_estab=Adoption*(temp_multiestab==1)
			drop temp_*	
			
			label var Adoption_multi_estab "Adop multi estab"
			label var Adoption_single_estab "Adop single estab"
				
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
			
			cap drop res
			reghdfe D.Adoption IV_NonAcc_real_2 D.Age_* , absorb($Controls) vce(cluster merchant_fuc) residuals(res)
			
		
			reghdfe D.(Log_TotalAmount Adoption_multi_estab Adoption_single_estab) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_multi_estab=D.Adoption_single_estab			
			
			reghdfe D.(Log_TotalAmount Adoption_multi_estab Adoption_single_estab) res D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test res
			test D.Adoption_multi_estab=D.Adoption_single_estab
			
			
		***********************************************************************************
		* TABLE 4B: HETEROGENEOUS EFFECTS I
		***********************************************************************************		
			
			bys merchant_postal_code merchant_category_id Date: gen temp_Competition_estabs=_N
			sum temp_Competition_estabs if  Adopter==1,d  
			egen temp_threshold = pctile(temp_Competition_estabs) if Adoption==1 & Adopter==1, p(50)

			gen Temp_High_comp= (temp_Competition_estabs>=temp_threshold & Adopter==1)
			drop temp_Competition_estabs temp_threshold
			
			// Size
			gen temp_quarter_pre=1 if Adopter==1 & Adoption==0   
			gen temp_amount_quater_pre= temp_quarter_pre*TotalAmount
			bys merchant_fuc: egen temp_mean_quarter_pre=mean(temp_amount_quater_pre)
			bys merchant_fuc: gen temp_first=(_n==1)
							
			egen temp_group=group(merchant_category_id)  
			gen temp_threshold=.
			levelsof temp_group, local(levels) 
			foreach l of local levels { 
				sum temp_mean_quarter_pre if temp_group==`l' & temp_first==1 & Adopter==1,d
				local temp_t=r(p50)
				replace temp_threshold=`temp_t' if temp_group==`l'
				}
			
			gen Temp_Big_size= (temp_mean_quarter_pre>=temp_threshold & Adopter==1)
			
			// Adoption categories
			gen Ad_Bsize_Hcomp=Adoption*(Temp_Big_size==1)*(Temp_High_comp==1)
			gen Ad_Bsize_Lcomp=Adoption*(Temp_Big_size==1)*(Temp_High_comp==0)
			gen Ad_Ssize_Hcomp=Adoption*(Temp_Big_size==0)*(Temp_High_comp==1)
			gen Ad_Ssize_Lcomp=Adoption*(Temp_Big_size==0)*(Temp_High_comp==0)
			cap drop temp* 
											
			
		* 1.  SOPHISTICATION CONTROLING FOR DIFFERENCES IN SIZE AND BUSINESS DENSITY
			
			reghdfe D.(Log_TotalAmount Adoption_high_soph Adoption_low_soph Adoption_BigSize Adoption_SmallSize Adoption_High_Comp Adoption_Low_Comp) D.Age_*	, absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_high_soph=D.Adoption_low_soph
						
			reghdfe D.(Log_TotalAmount Adoption_high_soph Adoption_low_soph Adoption_BigSize Adoption_SmallSize Adoption_High_Comp Adoption_Low_Comp) res D.Age_, absorb($Controls) vce(cluster merchant_fuc)
			test res
			test D.Adoption_high_soph=D.Adoption_low_soph
						
		* 2.  CLASIFY FIRMS BY COMPETITION & SIZE TOGETHER
			bys merchant_postal_code merchant_category_id Date: gen temp_Competition_estabs=_N
			sum temp_Competition_estabs if  Adopter==1,d  
			egen temp_threshold = pctile(temp_Competition_estabs) if Adoption==1 & Adopter==1, p(50)

			gen Temp_High_comp= (temp_Competition_estabs>=temp_threshold & Adopter==1)
			drop temp_Competition_estabs temp_threshold
			
			gen temp_quarter_pre=1 if Adopter==1 & Adoption==0   
			gen temp_amount_quater_pre= temp_quarter_pre*TotalAmount
			bys merchant_fuc: egen temp_mean_quarter_pre=mean(temp_amount_quater_pre)
			bys merchant_fuc: gen temp_first=(_n==1)
							
			egen temp_group=group(merchant_category_id)  
			gen temp_threshold=.
			levelsof temp_group, local(levels) 
			foreach l of local levels { 
				sum temp_mean_quarter_pre if temp_group==`l' & temp_first==1 & Adopter==1,d
				local temp_t=r(p50)
				replace temp_threshold=`temp_t' if temp_group==`l'
				}
			
			gen Temp_Big_size= (temp_mean_quarter_pre>=temp_threshold & Adopter==1)
			
			// Adoption categories
			gen Ad_Bsize_Hcomp=Adoption*(Temp_Big_size==1)*(Temp_High_comp==1)
			gen Ad_Bsize_Lcomp=Adoption*(Temp_Big_size==1)*(Temp_High_comp==0)
			gen Ad_Ssize_Hcomp=Adoption*(Temp_Big_size==0)*(Temp_High_comp==1)
			gen Ad_Ssize_Lcomp=Adoption*(Temp_Big_size==0)*(Temp_High_comp==0)
			cap drop temp* 
			
			xtset merchant_fuc Date
			
			global Controls="i.Date#i.Zone#i.Sector" 
			global Treatment="Ad_Bsize_Hcomp Ad_Bsize_Lcomp Ad_Ssize_Hcomp Ad_Ssize_Lcomp"
				
			reghdfe D.(Log_TotalAmount $Treatment) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test D.Ad_Bsize_Hcomp = D.Ad_Bsize_Lcomp = D.Ad_Ssize_Hcomp = D.Ad_Ssize_Lcomp	

			reghdfe D.(Log_TotalAmount $Treatment) res D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test res
			test D.Ad_Bsize_Hcomp = D.Ad_Bsize_Lcomp = D.Ad_Ssize_Hcomp = D.Ad_Ssize_Lcomp
				
	
				
		***********************************************************************************
		* TABLE 5: MECHANISMS TRANSACTIONS AND CUSTOMERS
		***********************************************************************************		
				
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
				
		* 1. DEP VAR: NUMBER OF CUSTOMERS
			reghdfe D.(Log_Customers Adoption) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
				
			ivreghdfe D.Log_Customers (D.Adoption = IV_NonAcc_real_2) D.Age_* , absorb($Controls) cluster(merchant_fuc)
								
		* 2. DEP VAR: REVENUE PER CUSTOMER
			gen Log_value_cust=log(TotalAmount/Customers)
					
			reghdfe D.(Log_value_cust Adoption) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
				
			ivreghdfe D.Log_value_cust (D.Adoption = IV_NonAcc_real_2) D.Age_*, absorb($Controls) cluster(merchant_fuc)	
				
		* 3. DEP VAR: TRANSACTIONS PER CUSTOMER
			gen Log_trans_cust=log(Transactions/Customers)

			reghdfe D.(Log_trans_cust Adoption) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
				
			ivreghdfe D.Log_trans_cust (D.Adoption = IV_NonAcc_real_2) D.Age_*, absorb($Controls) cluster(merchant_fuc)	
				
		* 4. DEP VAR: NUMBER TRANSACTIONS
			reghdfe D.(Log_Transactions Adoption ) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)				
				
			ivreghdfe D.Log_Transactions (D.Adoption = IV_NonAcc_real_2) D.Age_* , absorb($Controls) cluster(merchant_fuc)  
				
		* 5. DEP VAR: REVENUE PER TRANSACTION					
			reghdfe D.(Log_AverageAmount Adoption ) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
				
			ivreghdfe D.Log_AverageAmount (D.Adoption = IV_NonAcc_real_2) D.Age_*, absorb($Controls) cluster(merchant_fuc)	
						
			clear
		
		
		***********************************************************************************
		* TABLE 6: MECHANISMS AGE-GENDER GROUPS 
		***********************************************************************************	
		
			use "Gender_final.dta"
	
		*  CLASIFY FIRMS BY SHARE IN MAIN GROUP IN THE QUARTERS PRE-ADOPTION
			gen temp_quarter_pre=.
			replace temp_quarter_pre=1 if (Adopter==1 & Adoption==0)
			sort merchant_fuc Date
			bys merchant_fuc: gen temp_first=(_n==1)
			
			foreach x in sum {
				gen temp_`x'_quater_pre= temp_quarter_pre*Share_`x'_Max
				bys merchant_fuc: egen temp_mean_`x'_quarter_pre=mean(temp_`x'_quater_pre)
				
				br merchant_fuc Date Adopter Adoption temp_* if Adopter==1
				
				gen temp_threshold_`x'=.
				sum temp_mean_`x'_quarter_pre if temp_first==1 & Adopter==1,d
				replace temp_threshold_`x'=r(p50)
				
				gen temp_Large_`x'= (temp_mean_`x'_quarter_pre>=temp_threshold_`x' & Adopter==1)
				gen temp_Small_`x'= (temp_mean_`x'_quarter_pre<temp_threshold_`x' & Adopter==1)
				
				gen Adoption_LargeShare_`x'=Adoption*(temp_Large_`x'==1)
				gen Adoption_SmallShare_`x'=Adoption*(temp_Small_`x'==1)
				
				}
			
			drop temp_* 
			label var Adoption_LargeShare_sum "Adoption Large Share pre-adopt"
			label var Adoption_SmallShare_sum "Adoption Small Share pre-adopt"
		
			xtset merchant_fuc Date
			eststo clear
			global Controls="i.Date#i.Zone#i.Sector"
		
		
		* 1. BASELINE    
			reghdfe D.(Share_sum_Max Adoption) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			
			ivreghdfe D.Share_sum_Max (D.Adoption = IV_NonAcc_real_2) D.Age_* ,	absorb($Controls) cluster(merchant_fuc)  
		
		* 2. HETEROGENEOUS EFFECTS
			
			reghdfe D.(Share_sum_Max Adoption_LargeShare_sum Adoption_SmallShare_sum) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_LargeShare_sum = D.Adoption_SmallShare_sum
						
			reghdfe D.Adoption IV_NonAcc_real_2 D.Age_* , absorb($Controls) vce(cluster merchant_fuc) residuals(res)
			
			reghdfe D.(Share_sum_Max Adoption_LargeShare_sum Adoption_SmallShare_sum) res D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test res
			test D.Adoption_LargeShare_sum = D.Adoption_SmallShare_sum
			
					
		*  CLASIFY FIRMS BY HHI IN THE QUARTERS PRE-ADOPTION
			gen temp_quarter_pre=.
			replace temp_quarter_pre=1 if (Adopter==1 & Adoption==0)
			sort merchant_fuc Date
			bys merchant_fuc: gen temp_first=(_n==1)
			
			foreach x in sum {
			*local x="sum"
				gen temp_`x'_quater_pre= temp_quarter_pre*HHI_`x'
				bys merchant_fuc: egen temp_mean_`x'_quarter_pre=mean(temp_`x'_quater_pre)
				
				br merchant_fuc Date Adopter Adoption temp_* if Adopter==1
				
				gen temp_threshold_`x'=.
				sum temp_mean_`x'_quarter_pre if temp_first==1 & Adopter==1,d
				replace temp_threshold_`x'=r(p50)
				
				gen temp_Large_`x'= (temp_mean_`x'_quarter_pre>=temp_threshold_`x' & Adopter==1)
				gen temp_Small_`x'= (temp_mean_`x'_quarter_pre<temp_threshold_`x' & Adopter==1)
				
				gen Adoption_LargeHHI_`x'=Adoption*(temp_Large_`x'==1)
				gen Adoption_SmallHHI_`x'=Adoption*(temp_Small_`x'==1)
				
				}
			
			drop temp_* 
			
			label var Adoption_LargeHHI_sum "Adoption High HHI pre-adopt"
			label var Adoption_SmallHHI_sum "Adoption Low HHI pre-adopt"
			
			label var HHI_sum "HHI revenue"
			gen Log_HHI_sum=log(HHI_sum)
			label var Log_HHI_sum "Log HHI revenue"	
			
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector"
		
		
		* 3. BASELINE HHI ANALYSIS    
			reghdfe D.(Log_HHI_sum Adoption) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			
			ivreghdfe D.Log_HHI_sum (D.Adoption = IV_NonAcc_real_2) D.Age_* , absorb($Controls) cluster(merchant_fuc)  

		
		* 4. HETEROGENEOUS EFFECTS HHI ANALYSIS
			
			reghdfe D.(Log_HHI_sum Adoption_LargeHHI_sum Adoption_SmallHHI_sum) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_LargeHHI_sum = D.Adoption_SmallHHI_sum
			
			reghdfe D.(Log_HHI_sum  Adoption_LargeHHI_sum  Adoption_SmallHHI_sum) res D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test res
			test D.Adoption_LargeHHI_sum = D.Adoption_SmallHHI_sum			
				
			clear
			
			
		***********************************************************************************
		* TABLE 7: ANALYSIS OF SHARE OF SALES IN NON-LOCAL ZIPCODE
		***********************************************************************************	
			
			use "Zipcode_final.dta"	
	
		*  CLASIFY FIRMS BY HHI IN THE QUARTERS PRE-ADOPTION
			gen temp_quarter_pre=.
			replace temp_quarter_pre=1 if (Adopter==1 & Adoption==0)
			sort merchant_fuc Date
			bys merchant_fuc: gen temp_first=(_n==1)
			
			foreach x in sum {  
				gen temp_`x'_quater_pre= temp_quarter_pre*Share_`x'NO
				bys merchant_fuc: egen temp_mean_`x'_quarter_pre=mean(temp_`x'_quater_pre)
				
				br merchant_fuc Date Adopter Adoption temp_* if Adopter==1
				
				gen temp_threshold_`x'=.
				sum temp_mean_`x'_quarter_pre if temp_first==1 & Adopter==1,d
				replace temp_threshold_`x'=r(p50)
				
				gen temp_Large_`x'= (temp_mean_`x'_quarter_pre>=temp_threshold_`x' & Adopter==1)
				gen temp_Small_`x'= (temp_mean_`x'_quarter_pre<temp_threshold_`x' & Adopter==1)
				
				gen Adoption_LargeShare_`x'=Adoption*(temp_Large_`x'==1)
				gen Adoption_SmallShare_`x'=Adoption*(temp_Small_`x'==1)
				
				}
			
			drop temp_* 
			
			label var Adoption_LargeShare_sum "Adoption Large Share out pre-adopt"
			label var Adoption_SmallShare_sum "Adoption Small Share out pre-adopt"

			label var Share_txsNO "Trans_out_PC"
			label var Share_sumNO "Rev_out_PC"
			
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector"
				
		* 1. BASELINE    
			reghdfe D.(Share_sumNO Adoption) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			
			ivreghdfe D.Share_sumNO (D.Adoption = IV_NonAcc_real_2) D.Age_* ,	absorb($Controls) cluster(merchant_fuc)  

		* 2. HETEROGENEOUS EFFECTS
			
			reghdfe D.(Share_sumNO Adoption_LargeShare_sum Adoption_SmallShare_sum) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_LargeShare_sum = D.Adoption_SmallShare_sum
			
			reghdfe D.Adoption IV_NonAcc_real_2 D.Age_* , absorb($Controls) vce(cluster merchant_fuc) residuals(res)
			
			reghdfe D.(Share_sumNO Adoption_LargeShare_sum Adoption_SmallShare_sum) res D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test res
			test D.Adoption_LargeShare_sum = D.Adoption_SmallShare_sum
					
			clear
				
	
		***********************************************************************************	
		* TABLE 8: SHARE OF SALES AMONG HOURS OF SHOPPING 
		***********************************************************************************	

			use "Horas_final.dta"	
		
			gen Log_sum_Max_hours=log(1+sum_Max_hours)
			gen TotalAmount_valle=TotalAmount-sum_Max_hours
			gen Log_TotalAmount_valle=log(1+TotalAmount_valle) 
			
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector"
		
		* 1. BASELINE EFFECT ON PEAK SALES
			reghdfe D.(Log_sum_Max_hours Adoption) D.Age_*  , absorb($Controls) vce(cluster merchant_fuc)
			
			ivreghdfe D.Log_sum_Max_hours (D.Adoption = IV_NonAcc_real_2) D.Age_*  , absorb($Controls) cluster(merchant_fuc) 
				
		* 2. BASELINE EFFECT ON OFF-PEAK SALES
			reghdfe D.(Log_TotalAmount_valle Adoption) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			
			ivreghdfe D.Log_TotalAmount_valle (D.Adoption = IV_NonAcc_real_2) D.Age_* , absorb($Controls) cluster(merchant_fuc) 
				
		* 3. BASELINE: YES ALL CONTROLS
			reghdfe D.(Log_TotalAmount_valle Adoption) D.Age_* D.Log_sum_in_* D.Log_sumYES D.Log_sumNO , absorb($Controls) vce(cluster merchant_fuc)
			
			ivreghdfe D.Log_TotalAmount_valle (D.Adoption = IV_NonAcc_real_2) D.Age_* D.Log_sum_in_* D.Log_sumYES D.Log_sumNO , absorb($Controls) cluster(merchant_fuc)	
				
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector"  
				
		* 4. BASELINE: NO CONTROL
			reghdfe D.(Log_HHI_sum_hours Adoption) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			
			ivreghdfe D.Log_HHI_sum_hours (D.Adoption = IV_NonAcc_real_2) D.Age_* ,	absorb($Controls) cluster(merchant_fuc) 
							
		* 5. BASELINE: YES ALL CONTROLS
			forval i=1(1)12{
			cap gen Log_sum_in_`i'=log(1+sum`i')
			cap ren sum`i' sum_in_`i'
			cap ren Share_sum`i' Share_sum_in_`i'
			}	
			
			gen Log_sumYES=log(1+sumYES)
			gen Log_sumNO=log(1+sumNO)
			
			reghdfe D.(Log_HHI_sum_hours Adoption) D.Age_* D.Log_sum_in_* D.Log_sumYES D.Log_sumNO , absorb($Controls) vce(cluster merchant_fuc)
			
			ivreghdfe D.Log_HHI_sum_hours (D.Adoption = IV_NonAcc_real_2) D.Age_* D.Log_sum_in_* D.Log_sumYES D.Log_sumNO , absorb($Controls) cluster(merchant_fuc)

			clear
				
		******************************************************************************************************************	
		*  TABLE 9: HETEROGENEOUS BY SHARE OF TRANSACTIONS BY CREDIT CARD VS CASH
		******************************************************************************************************************	
		
			use "Short_Final_Main.dta", clear 
				
			cap drop Card_Sector Adoption_Card_Sector Adoption_Cash_Sector
				
			gen Card_Sector=0
			replace Card_Sector=1 if Sector==101 | Sector==105 | Sector==107 | Sector==113 | Sector==115 | Sector==117 
				
			gen Adoption_Card_Sector= Adoption*(Card_Sector==1)
			gen Adoption_Cash_Sector= Adoption*(Card_Sector==0)
				
			xtset merchant_fuc Date
			global Regressors="Adoption_Card_Sector Adoption_Cash_Sector"
			global Controls="i.Date#i.Zone#i.Sector" 
				
		* Generating the IV
			reghdfe D.Adoption IV_NonAcc_real_2 D.Age_*	, absorb($Controls) vce(cluster merchant_fuc) residuals(res)
				
		* Regressions
			reghdfe D.(Log_TotalAmount $Regressors) D.Age_*, absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_Card_Sector = D.Adoption_Cash_Sector
			
			reghdfe D.(Log_TotalAmount $Regressors ) D.Age_* res, absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_Card_Sector = D.Adoption_Cash_Sector
				
				
			
		***********************************************************************************
		* TABLE 10: EFFECTS ON CLOSE COMPETITORS 
		***********************************************************************************								 
				
			xtset merchant_fuc Date
			gen temp_diff_adoption=D.Adoption
			replace temp_diff_adoption=0 if temp_diff_adoption==.
				
			sort Date
			bys Date: gen temp_1 =(_n==1)
			gen temp_2=sum(temp_1)
			gen temp_3=temp_2^2
			br Date temp_1 temp_2
						
		* 1. SECTOR	CONTROL
			bys merchant_category_id merchant_postal_code Date: egen temp_affected_1=max(temp_diff_adoption)
			replace temp_affected_1=0 if temp_diff_adoption==1
				
			xtset merchant_fuc Date
			global Controls="i.Date#i.Sector"
				
			reghdfe D.(Log_TotalAmount  Adoption) temp_affected_1 D.Age_* , absorb($Controls c.temp_2#i.merchant_category_id#i.Zone ) vce(cluster merchant_fuc)
										
		* 2. BASELINE		
			bys merchant_sub_category_id merchant_postal_code Date: egen temp_affected_2=max(temp_diff_adoption)
			replace temp_affected_2=0 if temp_diff_adoption==1
												
			xtset merchant_fuc Date
			global Controls="i.Date#i.Sector#i.Zone"
				
			reghdfe D.(Log_TotalAmount Adoption) temp_affected_2  D.Age_* , absorb($Controls c.temp_2#i.merchant_sub_category_id#i.Zone ) vce(cluster merchant_fuc) 
				
			drop res
				
			reghdfe D.Adoption IV_NonAcc_real_2 temp_affected_2 D.Age_* , absorb($Controls c.temp_2#i.merchant_sub_category_id#i.Zone ) ///
				vce(cluster merchant_fuc) residuals(res)
				
			reghdfe D.(Log_TotalAmount Adoption) temp_affected_2 D.Age_* res , absorb($Controls c.temp_2#i.merchant_sub_category_id#i.Zone ) vce(cluster merchant_fuc) 
				
			drop res
		
		* 3. ADOPTERS OUT
			reghdfe D.(Log_TotalAmount) temp_affected_2  D.Age_* if Adopter==0, absorb($Controls c.temp_2#i.merchant_sub_category_id#i.Zone ) vce(cluster merchant_fuc) 
				
		* 4. AFFECTED ONLY BY THE FIRST ADOPTER & ADOPTERS INCLUDED
			sort merchant_fuc Date
			replace temp_affected_2=temp_affected_2[_n-1] if merchant_fuc==merchant_fuc[_n-1] & temp_affected_2[_n-1]==1
			replace temp_affected_2=0 if Adopter==1
			br merchant_fuc Date temp_affected_2
				
			reghdfe D.(Log_TotalAmount Adoption temp_affected_2)   D.Age_* , absorb($Controls c.temp_2#i.merchant_sub_category_id#i.Zone ) vce(cluster merchant_fuc)
				
			reghdfe D.Adoption IV_NonAcc_real_2 D.temp_affected_2 D.Age_* , absorb($Controls c.temp_2#i.merchant_sub_category_id#i.Zone ) vce(cluster merchant_fuc) residuals(res)
				
			reghdfe D.(Log_TotalAmount Adoption temp_affected_2)  D.Age_* res , absorb($Controls c.temp_2#i.merchant_sub_category_id#i.Zone ) vce(cluster merchant_fuc) 
				
				
		* 5. AFFECTED ONLY BY THE FIRST ADOPTER & ADOPTERS NON-INCLUDED
			reghdfe D.(Log_TotalAmount temp_affected_2) D.Age_* if Adopter==0 , absorb($Controls c.temp_2#i.merchant_sub_category_id#i.Zone ) vce(cluster merchant_fuc)
				
		* 6. CLASIFY FIRMS BY COMPETITION IN ALL QUARTERS AT SUB-SECTOR-ZIPCODE LEVEL
			cap drop temp_Competition_estabs 
			cap drop temp_threshold 
			cap drop temp_Big 
			cap drop temp_Small 
			cap drop temp_first 
			cap drop Affected*
								
			bys merchant_postal_code merchant_sub_category_id Date: gen temp_Competition_estabs=_N
			bys merchant_postal_code merchant_sub_category_id Date: gen temp_first=(_n==1)
			sum temp_Competition_estabs if Adoption==1,d  
			egen temp_threshold = pctile(temp_Competition_estabs), p(50)

			gen temp_Big= (temp_Competition_estabs>=temp_threshold)
			gen temp_Small= (temp_Competition_estabs<temp_threshold)
				
			gen Affected_High_Comp_sub=temp_affected_2*(temp_Big==1)  
			gen Affected_Low_Comp_sub=temp_affected_2*(temp_Small==1)
	
			xtset merchant_fuc Date
			global Controls="i.Date#i.Sector#i.Zone"
				
			reghdfe D.(Log_TotalAmount Adoption) Affected_High_Comp_sub Affected_Low_Comp_sub  D.Age_* ,absorb($Controls c.temp_2#i.merchant_sub_category_id#i.Zone ) vce(cluster merchant_fuc)
			test Affected_High_Comp_sub = Affected_Low_Comp_sub
				
			clear

		***********************************************************************************
		* TABLE 11: AGGREGATE EFFECTS
		***********************************************************************************								 
	
			use "Short_Final_Main.dta"
		
			collapse (sum) Customers TotalAmount Transactions Adoption,by(merchant_postal_code  Date  merchant_category_id merchant_sub_category_id)
		 		
			egen Subsector= group(merchant_sub_category_id)
			egen Sector= group(merchant_category_id)
			egen Zone= group(merchant_postal_code)
		
			bys Subsector Zone Date: gen N=_N
			tab N
			drop if N>1
			drop N
		
			gen Adoption_Dummy=1
			replace Adoption_Dummy=0 if Adoption==0
		 
			gen lnamount=ln(TotalAmount)
			gen lncustomers=ln(Customers)
			gen lntrans=ln(Transactions)
		  
			egen Sector_zipcode=group(Zone Sector)
			egen Subsector_zipcode=group(Zone Subsector)
		  
			xtset Subsector_zipcode Date
			global Controls="i.Date#i.Zone#i.Sector"
			
			reghdfe D.(lnamount  Adoption_Dummy), absorb($Controls ) vce(cluster merchant_postal_code)
			
			xtset Subsector_zipcode Date
			global Controls="i.Date#i.Zone#i.Sector i.Subsector#i.Zone"
			
			reghdfe D.(lnamount  Adoption_Dummy), absorb($Controls ) vce(cluster merchant_postal_code)
			
			xtset Subsector_zipcode Date
			global Controls="i.Date#i.Zone#i.Sector i.Subsector#i.Zone i.Subsector#i.Date"
			
			reghdfe D.(lnamount  Adoption_Dummy), absorb($Controls ) vce(cluster merchant_postal_code)

			
		* Adoption OS meaning Adoption other sectors *
			cap drop totaladoption Adoption_OS resid_103
			 
			bys Date Subsector: egen totaladoption=total(Adoption_Dummy)
			gen Adoption_OS=totaladoption -Adoption_Dummy
			
			xtset Subsector_zipcode Date
			global Controls="i.Date#i.Zone#i.Sector i.Subsector#i.Zone"
			
			reghdfe D.(Adoption_Dummy Adoption_OS), absorb($Controls ) vce(cluster merchant_postal_code) residuals(resid_103)
			
			xtset Subsector_zipcode Date			
			reghdfe D.(lnamount  Adoption_Dummy) resid_103, absorb($Controls ) vce(cluster merchant_postal_code) 
			
			clear


		
	*********************************************
	*********************************************	
	************* APPENDIX A TABLES *************
	*********************************************
	*********************************************

			*---------------------------------------------------------------------------	
			* TABLE A1: COUNT OF ESTABLISHMENTS PER SECTOR AND SUBSECTOR	
			*---------------------------------------------------------------------------	

			use "Short_Final_Main.dta"
			
			collapse Sector subSECTOR,by(merchant_fuc)
			
			tab Sector
			tab subSECTOR
			tab2 Sector subSECTOR
			
			clear
			
			*---------------------------------------------------------------------------	
			* TABLE A2: ROBUSTNESS CHECKS TO MAIN RESULTS	
			*---------------------------------------------------------------------------	

			use "Short_Final_Main.dta"

			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector"
			
		* 1. FIRM SPECIFIC TRENDS									
		
			reghdfe D.(Log_TotalAmount Adoption) D.Age_* , absorb($Controls merchant_fuc) vce(cluster merchant_fuc)
				
			reghdfe D.Adoption IV_NonAcc_real_2 D.Age_* , absorb($Controls merchant_fuc) vce(cluster merchant_fuc) 
				
			ivreghdfe D.Log_TotalAmount (D.Adoption = IV_NonAcc_real_2) D.Age_* ,absorb($Controls merchant_fuc) cluster(merchant_fuc)

				
		* 2. FE AT THE SUBSECTOR LEVEL
		
			global Controls="i.Date#i.Zone#i.merchant_sub_category_id"
				
			reghdfe D.Log_TotalAmount D.Adoption D.Age_*, absorb($Controls ) vce(cluster merchant_fuc) 
				
			reghdfe D.Adoption IV_NonAcc_real_2 D.Age_* , absorb($Controls) vce(cluster merchant_fuc) 

			ivreghdfe D.Log_TotalAmount (D.Adoption = IV_NonAcc_real_2) D.Age_* ,absorb($Controls) cluster(merchant_fuc)   first
				
			global Controls="i.Date#i.Zone#i.Sector"	
				
			
		* 3. USING IV WITH NO ADOPTERS IN SAME SECTOR
			
			merge m:1 tx_merchant_branch Date merchant_category_id using "IV_NonAcc_real_3.dta", keepusing(IV_NonAcc_real_3)
			drop if _merge==2
			drop _merge
			replace IV_NonAcc_real_3=0 if IV_NonAcc_real_3==.
			replace IV_NonAcc_real_3= IV_NonAcc_real_2 - IV_NonAcc_real_3
				
			xtset merchant_fuc Date
				
			reghdfe D.Adoption IV_NonAcc_real_3 D.Age_* , absorb($Controls) vce(cluster merchant_fuc) 
								
			ivreghdfe D.Log_TotalAmount (D.Adoption = IV_NonAcc_real_3) D.Age_* , absorb($Controls) cluster(merchant_fuc)   	
	
			clear
			
			*---------------------------------------------------------------------------	
			* TABLE A3:	HETEROGENEOUS RESULTS BY EARLY VS LATE ADOPTERS
			*---------------------------------------------------------------------------	

			use "Short_Final_Main.dta"
				
		
		* 1. Early vs late adopters
						
			bys merchant_fuc: gen temp_1=_n
			
			sum Fuc_quarter_created if temp_1==1 & Adopter==1,d
			local temp_threshold=r(p50)
				
			gen Adoption_Early= Adoption*(Fuc_quarter_created<`temp_threshold')
			gen Adoption_Late= Adoption*(Fuc_quarter_created>=`temp_threshold')
	
			xtset merchant_fuc Date
			eststo clear
			global Regressors="Adoption_Early Adoption_Late"
			global Controls="i.Date#i.Zone#i.Sector" 
				
				
			* Generating the IV
			reghdfe D.Adoption IV_NonAcc_real_2 D.Age_*	, absorb($Controls) vce(cluster merchant_fuc) residuals(res)
				
				
			* Baseline
			reghdfe D.(Log_TotalAmount $Regressors) D.Age_*, absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_Early = D.Adoption_Late

			reghdfe D.(Log_TotalAmount $Regressors ) D.Age_* res, absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_Early = D.Adoption_Late
				
			drop Adoption_Early Adoption_Late
				
			
		* 2. Pilot vs no pilot		
			cap drop Pilot
			gen Pilot=(Fuc_quarter_created<=qofd(mdy(6,30,2016)))
			gen Adoption_Early=Adoption*Pilot
			gen Adoption_Late=Adoption*(Pilot==0)
				
				* Counding pilot adopters
				bys merchant_fuc: gen temp_first=_n==1
				tab Pilot if temp_first==1 & Adopter==1
				drop temp_first
										
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
			global Regressors="Adoption_Early Adoption_Late"
				
			reghdfe D.(Log_TotalAmount $Regressors) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_Early = D.Adoption_Late

			reghdfe D.(Log_TotalAmount $Regressors ) D.Age_* res, absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_Early = D.Adoption_Late
				
			drop Adoption_Early Adoption_Late
								
		* 3. First adopter in a market vs later adopters
			bys Zone Sector: egen temp_first_adoption=min(Fuc_quarter_created)
			gen temp_first_adopter=(Fuc_quarter_created==temp_first_adoption)
			gen temp_later_adopter=(Fuc_quarter_created!=temp_first_adoption)
				
			gen Adoption_Early=Adoption*temp_first_adopter
			gen Adoption_Late=Adoption*temp_later_adopter
				
				*Counting first adopters (second or laters is just the difference)
				bys merchant_fuc: gen temp_first=_n==1
				tab temp_first_adopter if temp_first==1 & Adopter==1
				drop temp_first
					
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
			global Regressors="Adoption_Early Adoption_Late"
				
			reghdfe D.(Log_TotalAmount $Regressors) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_Early = D.Adoption_Late

			reghdfe D.(Log_TotalAmount $Regressors ) D.Age_* res, absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_Early = D.Adoption_Late
				
			drop Adoption_Early Adoption_Late
				
						
		* 4. Sign-Up Time 
				
			cap drop Adoption_Early Adoption_Late   
			cap drop temp* created		
				
			merge m:1 merchant_fuc using "$path_menory/Batch_December_2018/Working_dta/fucs_2018_07_17.dta", keepusing(Fuc_created)
			drop if _merge==2
			drop _merge 
				
			gen temp_created_month=month(Fuc_created)
			gen temp_created_day=day(Fuc_created)
					
			cap drop time
			gen time=30-temp_created_day
			replace time=time+60 if temp_created_month==1 | temp_created_month==4 | temp_created_month==7 | temp_created_month==10
			replace time=time+30 if temp_created_month==2 | temp_created_month==5 | temp_created_month==8 | temp_created_month==11
				
			bys merchant_fuc: gen temp_1=_n
				
			sum time if temp_1==1 & Adopter==1,d
			local temp_threshold=r(p75)
				
			gen Adoption_Early= Adoption*(time >=`temp_threshold')
			gen Adoption_Late= Adoption*(time <`temp_threshold')
					
			xtset merchant_fuc Date
			global Regressors="Adoption_Early Adoption_Late"
			global Controls="i.Date#i.Zone#i.Sector" 
			
			reghdfe D.(Log_TotalAmount $Regressors) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_Early = D.Adoption_Late

			reghdfe D.(Log_TotalAmount $Regressors) D.Age_* res, absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_Early = D.Adoption_Late

			drop Adoption_Early Adoption_Late
				
			clear
				
			*---------------------------------------------------------------------------	
			* TABLE A4: AUTOCORRELATION	
			*---------------------------------------------------------------------------	
			
			use "Short_Final_Main.dta"
				
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
				
			sort  merchant_fuc Date
								
			gen Adoption_m1=Adoption
			replace Adoption_m1=1 if Adoption==0 & Adoption[_n+1]==1 & merchant_fuc==merchant_fuc[_n+1]
				
			gen Adoption_m2=Adoption_m1
			replace Adoption_m2=1 if Adoption_m1==0 & Adoption_m1[_n+1]==1 & merchant_fuc==merchant_fuc[_n+1]
				
			bys Sector Zone Date: egen maxAdoption=max(Adoption)
			bys Sector Zone Date: egen maxAdoption_m1=max(Adoption_m1)
			bys Sector Zone Date: egen maxAdoption_m2=max(Adoption_m2)
				
			keep if (maxAdoption==1| maxAdoption_m1==1| maxAdoption_m2==1)

			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
				
			reghdfe D.(Log_TotalAmount Adoption) Age_* , absorb(i.Date#i.Zone#i.Sector) vce(cluster merchant_fuc) 

			cap drop res
			reghdfe D.Adoption IV_NonAcc_real_2 D.Age_* , absorb($Controls) vce(cluster merchant_fuc) residuals(res)
						
			reghdfe D.(Log_TotalAmount Adoption) res D.Age_* , absorb($Controls) vce(cluster  merchant_fuc) 
			test res  
				
			clear			
			
			
			*---------------------------------------------------------------------------	
			* TABLE A5: STAGGERED ADOPTION I	
			*---------------------------------------------------------------------------	
			
			use "Short_Final_Main.dta"
				
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
				
			reghdfe D.(Log_TotalAmount Adoption) D.Age_* , absorb($Controls) vce(cluster merchant_fuc) 
					
			bys Sector Zone Date: egen sumAdoption=sum(Adoption)
			tab sumAdoption
			gen multiple=1
			replace multiple=0 if sumAdoption==0
			replace multiple=0 if sumAdoption==1
					
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
				
			reghdfe D.(Log_TotalAmount Adoption) D.Age_* if multiple==0 , absorb($Controls) vce(cluster merchant_fuc) 

			cap drop res
			reghdfe D.Adoption IV_NonAcc_real_2 D.Age_* , absorb($Controls) vce(cluster merchant_fuc) residuals(res)

			reghdfe D.(Log_TotalAmount Adoption) D.Age_* res if multiple==0 , absorb($Controls) vce(cluster merchant_fuc) 
			
			
			*---------------------------------------------------------------------------	
			* TABLE A6: STAGGERED ADOPTION II	
			*---------------------------------------------------------------------------	
			
			
			reghdfe D.Log_TotalAmount D.Age_* , absorb($Controls) vce(cluster merchant_fuc) residuals(resid)
				
			egen treatmentgroup=group(Fuc_quarter_created)				
			replace treatmentgroup=0 if Fuc_quarter_created==.

			gen tgroup=treatmentgroup+3
			replace tgroup=0 if Fuc_quarter_created==.

			gen t=Date-215
				
			bys merchant_fuc: gen N=_N

			csdid resid, cluster(merchant_fuc) time(t) gvar(tgroup) method(dripw) notyet agg(simple)
			csdid resid, cluster(merchant_fuc) time(t) gvar(tgroup) method(dripw) notyet agg(group)
			csdid resid, cluster(merchant_fuc) time(t) gvar(tgroup) method(dripw) notyet agg(event)

			csdid resid if N==20, cluster(merchant_fuc) time(t) gvar(tgroup) method(dripw) notyet agg(simple)
			csdid resid if N==20, cluster(merchant_fuc) time(t) gvar(tgroup) method(dripw) notyet agg(group)
			csdid resid if N==20, cluster(merchant_fuc) time(t) gvar(tgroup) method(dripw) notyet agg(event)

			csdid resid if multiple==0, cluster(merchant_fuc) time(t) gvar(tgroup) method(dripw) notyet agg(simple)
			csdid resid if multiple==0, cluster(merchant_fuc) time(t) gvar(tgroup) method(dripw) notyet agg(group)
			csdid resid if multiple==0, cluster(merchant_fuc) time(t) gvar(tgroup) method(dripw) notyet agg(event)

			csdid resid if N==20 & multiple==0, cluster(merchant_fuc) time(t) gvar(tgroup) method(dripw) notyet agg(simple)
			csdid resid if N==20 & multiple==0, cluster(merchant_fuc) time(t) gvar(tgroup) method(dripw) notyet agg(group)
			csdid resid if N==20 & multiple==0, cluster(merchant_fuc) time(t) gvar(tgroup) method(dripw) notyet agg(event)

			clear
			
			
			*---------------------------------------------------------------------------	
			* TABLE A7: ROBUSTNESS CHECKS MECHANISMS AGE-GENDER GROUPS	
			*---------------------------------------------------------------------------	
			
			use "Gender_final.dta"
								
			gen temp_quarter_pre=.
			replace temp_quarter_pre=1 if (Adopter==1 & Adoption==0)
			sort merchant_fuc Date
			bys merchant_fuc: gen temp_first=(_n==1)
			
			foreach x in sum {
				gen temp_`x'_quater_pre= temp_quarter_pre*Share_`x'_Max
				bys merchant_fuc: egen temp_mean_`x'_quarter_pre=mean(temp_`x'_quater_pre)
				
				br merchant_fuc Date Adopter Adoption temp_* if Adopter==1
				
				gen temp_threshold_`x'=.
				sum temp_mean_`x'_quarter_pre if temp_first==1 & Adopter==1,d
				replace temp_threshold_`x'=r(p50)
				
				gen temp_Large_`x'= (temp_mean_`x'_quarter_pre>=temp_threshold_`x' & Adopter==1)
				gen temp_Small_`x'= (temp_mean_`x'_quarter_pre<temp_threshold_`x' & Adopter==1)
				
				gen Adoption_LargeShare_`x'=Adoption*(temp_Large_`x'==1)
				gen Adoption_SmallShare_`x'=Adoption*(temp_Small_`x'==1)
				
				}
			
			drop temp_* 
			label var Adoption_LargeShare_sum "Adoption Large Share pre-adopt"
			label var Adoption_SmallShare_sum "Adoption Small Share pre-adopt"
		
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector"
				
		* 1. BASELINE EFFECT ON SALES TO PRIME CUSTOMER   
			gen Log_sum_Max=log(1+sum_Max)
			
			reghdfe D.(Log_sum_Max Adoption) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			
			ivreghdfe D.Log_sum_Max (D.Adoption = IV_NonAcc_real_2) D.Age_* , absorb($Controls) cluster(merchant_fuc)  

		* 2. HETEROGENEOUS EFFECTS ON SALES TO PRIME CUSTOMER
			
			reghdfe D.(Log_sum_Max Adoption_LargeShare_sum Adoption_SmallShare_sum) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_LargeShare_sum = D.Adoption_SmallShare_sum
			
			reghdfe D.(Log_sum_Max Adoption_LargeShare_sum Adoption_SmallShare_sum) res D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test res
			test D.Adoption_LargeShare_sum = D.Adoption_SmallShare_sum
						
		* 3. EFFECT ON SALES TO NON-PRIME CUSTOMER
			gen Log_Total_others=log(TotalAmount-sum_Max+1)
			
			reghdfe D.(Log_Total_others Adoption_LargeShare_sum Adoption_SmallShare_sum) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_LargeShare_sum = D.Adoption_SmallShare_sum
						
			reghdfe D.(Log_Total_others Adoption_LargeShare_sum Adoption_SmallShare_sum) res D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test res
			test D.Adoption_LargeShare_sum = D.Adoption_SmallShare_sum
			
			clear
						
			
			*---------------------------------------------------------------------------	
			* TABLE A8: ROBUSTNESS CHECKS HOURS OF SALES	
			*---------------------------------------------------------------------------
			
			use "Horas_final.dta", replace
		
			gen Log_Avg_value_peak=log((1+sum_Max_hours)/(1+txs_Max))	
			gen TotalAmount_off_peak=TotalAmount-sum_Max_hours
			gen TotalTxs_off_peak=Transactions-txs_Max
			gen Log_Avg_value_off_peak=log((1+TotalAmount_off_peak)/(1+TotalTxs_off_peak))
			
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector"
		
		* 1. BASELINE EFFECT ON PEAK SALES
			reghdfe D.(Log_Avg_value_peak Adoption) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			
			ivreghdfe D.Log_Avg_value_peak (D.Adoption = IV_NonAcc_real_2) D.Age_* , absorb($Controls) cluster(merchant_fuc) 
				
		* 2. BASELINE EFFECT ON OFF-PEAK SALES
			reghdfe D.(Log_Avg_value_off_peak Adoption) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			
			ivreghdfe D.Log_Avg_value_off_peak (D.Adoption = IV_NonAcc_real_2) D.Age_* , absorb($Controls) cluster(merchant_fuc) 
				
		* 3. BASELINE: YES ALL CONTROLS
			forval i=1(1)12{
			cap gen Log_sum_in_`i'=log(1+sum`i')
			cap ren sum`i' sum_in_`i'
			cap ren Share_sum`i' Share_sum_in_`i'
			}	
			
			g Log_sumYES=log(1+sumYES)
			g Log_sumNO=log(1+sumNO)
			
			
			reghdfe D.(Log_Avg_value_off_peak Adoption) D.Age_* D.Log_sum_in_* D.Log_sumYES D.Log_sumNO , absorb($Controls) vce(cluster merchant_fuc)
			
			ivreghdfe D.Log_Avg_value_off_peak (D.Adoption = IV_NonAcc_real_2) D.Age_* D.Log_sum_in_* D.Log_sumYES D.Log_sumNO  , absorb($Controls) cluster(merchant_fuc)	
		
			clear

	
	*********************************************	
	*********************************************	
	************* APPENDIX B TABLES *************
	*********************************************
	*********************************************

				
			*---------------------------------------------------------------------------	
			* TABLE B1: EVENT STUDY WITH ONLY ADOPTERS	
			*---------------------------------------------------------------------------		
		
			use "Short_Final_Main.dta"
					
			xtset merchant_fuc Date
			global Regressors="Adoption"
			eststo clear
			
			global Controls="i.Date" 
			reghdfe D.(Log_TotalAmount $Regressors) D.Age_*  if Adopter==1, absorb($Controls) vce(cluster merchant_fuc)

			global Controls="i.Date#i.Sector" 
			reghdfe D.(Log_TotalAmount $Regressors) D.Age_*  if Adopter==1, absorb($Controls) vce(cluster merchant_fuc)

			global Controls="i.Date#i.Zone" 
			reghdfe D.(Log_TotalAmount $Regressors) D.Age_*  if Adopter==1, absorb($Controls) vce(cluster merchant_fuc)

			global Controls="i.Date#i.Zone i.Date#i.Sector" 
			reghdfe D.(Log_TotalAmount $Regressors) D.Age_*  if Adopter==1, absorb($Controls) vce(cluster merchant_fuc)

			global Controls="i.Date#i.Zone i.Date#i.Sector" 
			ivreghdfe D.Log_TotalAmount (D.Adoption = IV_NonAcc_real_2) D.Age_* if Adopter==1, absorb($Controls) cluster(merchant_fuc)
					
			global Controls="i.Date#i.Zone#i.Sector" 
			reghdfe D.(Log_TotalAmount $Regressors) D.Age_*  if Adopter==1, absorb($Controls) vce(cluster merchant_fuc)
					
			global Controls="i.Date#i.Zone#i.Sector" 
			ivreghdfe D.Log_TotalAmount (D.Adoption = IV_NonAcc_real_2) D.Age_* if Adopter==1, absorb($Controls) cluster(merchant_fuc)
			
			
			*---------------------------------------------------------------------------	
			* TABLE B2: HETEROGENEOUS EFFECTS BY SOPHISTICATION MEASURES DISAGREGATED	
			*---------------------------------------------------------------------------	
			
			use "Short_Final_Main.dta"
				
			* analytical_user
			local x="analytical_user"
			cap drop Sophistication 
			gen Sophistication= `x'
			bys merchant_fuc: gen temp_1=_n==1
			gen temp_Soph_non_missing=analytical_user + marketing_user + digital_user
			replace temp_1=temp_1*(Adopter==1)*(temp_Soph_non_missing!=.)
			sum Sophistication if temp_1==1,d
			local temp_2=r(p50)
			dis "`temp_2'"
			gen temp_High_soph=(Sophistication>=`temp_2' & Sophistication!=.)
			gen temp_Low_soph=(Sophistication<`temp_2' & Sophistication!=.) 
			gen Adoption_high_soph=Adoption*temp_High_soph
			gen Adoption_low_soph=Adoption*(temp_High_soph==0)
			drop temp_*	
			
			label var Adoption_high_soph "Adop high"
			label var Adoption_low_soph "Adop low"
				
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
					
			reghdfe D.(Log_TotalAmount Adoption_high_soph Adoption_low_soph) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_high_soph=D.Adoption_low_soph
				
					
			reghdfe D.Adoption IV_NonAcc_real_2 D.Age_* , absorb($Controls) vce(cluster merchant_fuc) residuals(res)
					
			reghdfe D.(Log_TotalAmount Adoption_high_soph Adoption_low_soph) res D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test res
			test D.Adoption_high_soph=D.Adoption_low_soph

				
			* marketing_user
			local x="marketing_user"
			cap drop Sophistication Adoption_high_soph Adoption_low_soph
			gen Sophistication= `x'
			bys merchant_fuc: gen temp_1=_n==1
			gen temp_Soph_non_missing=analytical_user + marketing_user + digital_user
			replace temp_1=temp_1*(Adopter==1)*(temp_Soph_non_missing!=.)
			sum Sophistication if temp_1==1,d
			local temp_2=r(p50)
			dis "`temp_2'"
			gen temp_High_soph=(Sophistication>=`temp_2' & Sophistication!=.)
			gen temp_Low_soph=(Sophistication<`temp_2' & Sophistication!=.) 
			gen Adoption_high_soph=Adoption*temp_High_soph
			gen Adoption_low_soph=Adoption*(temp_High_soph==0)
			drop temp_*	
				
			label var Adoption_high_soph "Adop high"
			label var Adoption_low_soph "Adop low"
				
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
				
			reghdfe D.(Log_TotalAmount Adoption_high_soph Adoption_low_soph) D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_high_soph=D.Adoption_low_soph
					
			reghdfe D.(Log_TotalAmount Adoption_high_soph Adoption_low_soph) res D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test res
			test D.Adoption_high_soph=D.Adoption_low_soph

				
			* digital_user
			local x="digital_user"
			cap drop Sophistication Adoption_high_soph Adoption_low_soph
			gen Sophistication= `x'
			bys merchant_fuc: gen temp_1=_n==1
			gen temp_Soph_non_missing=analytical_user + marketing_user + digital_user
			replace temp_1=temp_1*(Adopter==1)*(temp_Soph_non_missing!=.)
			sum Sophistication if temp_1==1,d
			local temp_2=r(p50)
			dis "`temp_2'"
			gen temp_High_soph=(Sophistication>=`temp_2' & Sophistication!=.)
			gen temp_Low_soph=(Sophistication<`temp_2' & Sophistication!=.) 
			gen Adoption_high_soph=Adoption*temp_High_soph
			gen Adoption_low_soph=Adoption*(temp_High_soph==0)
			drop temp_*	
				
			label var Adoption_high_soph "Adop high"
			label var Adoption_low_soph "Adop low"
				
		
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
				
			reghdfe D.(Log_TotalAmount Adoption_high_soph Adoption_low_soph) D.Age_*	, absorb($Controls) vce(cluster merchant_fuc)
			test D.Adoption_high_soph=D.Adoption_low_soph
				
			reghdfe D.(Log_TotalAmount Adoption_high_soph Adoption_low_soph) res D.Age_*, absorb($Controls) vce(cluster merchant_fuc)
			test res
			test D.Adoption_high_soph=D.Adoption_low_soph	

			
			*---------------------------------------------------------------------------	
			* TABLE B3: HETEROGENEOUS EFFECTS BY SECTOR	
			*---------------------------------------------------------------------------	

			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
						
			forval x=101(1)118{  
				gen Adoption_`x'=Adoption*(Sector==`x')
				}
					
			reghdfe D.Log_TotalAmount D.Adoption_1* D.Age_* , absorb($Controls) vce(cluster merchant_fuc)

				
			*---------------------------------------------------------------------------	
			* TABLE B4: HETEROGENEOUS EFFECTS BY SUBSECTOR	
			*---------------------------------------------------------------------------	
					
				
			forval x=1(1)77{
				gen Adoption_`x'=Adoption*(merchant_sub_category_id==`x')
				}
					
			drop Adoption_falsification 
			reghdfe D.Log_TotalAmount D.Adoption_* 	, absorb($Controls) vce(cluster merchant_fuc)
				
			
			*---------------------------------------------------------------------------	
			* TABLE B5: HETEROGENEOUS EFFECTS BY PROVINCE	
			*---------------------------------------------------------------------------	

			
			forval x=1(1)52{
				gen Adoption_`x'=Adoption*(merchant_region==`x')
				}
					
			drop Adoption_falsification 
					
			reghdfe D.Log_TotalAmount D.Adoption_* , absorb($Controls) vce(cluster merchant_fuc)

			
			*---------------------------------------------------------------------------	
			* TABLE B6: HETEROGENEITY BY MONTH OF ADOPTION	
			*---------------------------------------------------------------------------	
						
			
			merge m:1 merchant_fuc using "E:\Analysis_Commerce_20220124\Analysis_Commerce_20220124\Batch_December_2018/Working_dta/fucs_2018_07_17.dta",keepusing(Fuc_month_created)
			
			drop if _merge==2
			drop _merge
			replace Fuc_month_created=. if Adopter==0
			
			tab Fuc_month_created
			gen month=month(dofm(Fuc_month_created))
			tab month
			
			gen temp_3bef=( month==1 | month==4 | month==7 | month==10)
			gen temp_2bef=( month==2 | month==5 | month==8 | month==11)
			gen temp_1bef=( month==3 | month==6 | month==9 | month==12)
			
			gen Adoption_3bef=Adoption*(temp_3bef==1)
			gen Adoption_2bef=Adoption*(temp_2bef==1)
			gen Adoption_1bef=Adoption*(temp_1bef==1)
			
			drop temp_*	
	
			xtset merchant_fuc Date
			eststo clear
			global Controls="i.Date#i.Zone#i.Sector" 
		
			reghdfe D.(Log_TotalAmount Adoption_1bef Adoption_2bef Adoption_3bef) D.Age_* , absorb($Controls ) vce(cluster merchant_fuc)
			test D.Adoption_1bef = D.Adoption_2bef = D.Adoption_3bef
			
			
			reghdfe D.(Log_TotalAmount Adoption_1bef Adoption_2bef Adoption_3bef) res D.Age_* , absorb($Controls) vce(cluster merchant_fuc)
			test res
			test D.Adoption_1bef = D.Adoption_2bef = D.Adoption_3bef
										
			drop Adoption_3bef Adoption_2bef Adoption_1bef

			clear
			
			*---------------------------------------------------------------------------	
			* TABLE B7: HETEROGENEITY BY DAY OF ADOPTION		
			*---------------------------------------------------------------------------	

			use "Short_Final_Main.dta"

			sort merchant_fuc

			merge merchant_fuc using "Info Adopters.dta" 

			gen day=day(Fuc_created)
			gen first=0
			replace first=1 if day<11
			replace first=0 if day==.

			gen second=0
			replace second=1 if day>10 & day<22
			replace second=0 if day==.

			gen third=0
			replace third=1 if day>21
			replace third=0 if day==.

			gen Adoption1st=Adoption*first
			gen Adoption2nd=Adoption*second
			gen Adoption3rd=Adoption*third

			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
														
			reghdfe D.(Log_TotalAmount Adoption1st Adoption2nd Adoption3rd) D.Age_* , absorb($Controls) vce(cluster merchant_fuc) 
			test D.Adoption1st = D.Adoption2nd = D.Adoption3rd

			cap drop res
			reghdfe D.Adoption IV_NonAcc_real_2 D.Age_* , absorb($Controls) vce(cluster merchant_fuc) residuals(res)
				
			reghdfe D.(Log_TotalAmount Adoption1st Adoption2nd Adoption3rd) res D.Age_* , absorb($Controls) vce(cluster  merchant_fuc) 
			test D.Adoption1st = D.Adoption2nd = D.Adoption3rd

			gen sampleA=1
			replace sampleA=0 if second==1
			replace sampleA=0 if third==1

			gen sampleB=1
			replace sampleB=0 if first==1
			replace sampleB=0 if third==1

			gen sampleC=1
			replace sampleC=0 if second==1
			replace sampleC=0 if first==1

			reghdfe D.(Log_TotalAmount Adoption1st) D.Age_* if sampleA==1, absorb($Controls) vce(cluster merchant_fuc) 

			reghdfe D.(Log_TotalAmount Adoption2nd) D.Age_* if sampleB==1, absorb($Controls) vce(cluster merchant_fuc) 

			reghdfe D.(Log_TotalAmount Adoption3rd) D.Age_* if sampleC==1, absorb($Controls) vce(cluster merchant_fuc) 
				
			reghdfe D.(Log_TotalAmount Adoption1st) D.Age_* res if sampleA==1, absorb($Controls) vce(cluster merchant_fuc) 

			reghdfe D.(Log_TotalAmount Adoption2nd) D.Age_* res if sampleB==1, absorb($Controls) vce(cluster merchant_fuc) 

			reghdfe D.(Log_TotalAmount Adoption3rd) D.Age_* res if sampleC==1, absorb($Controls) vce(cluster merchant_fuc) 

						
			*---------------------------------------------------------------------------	
			* TABLE B8: DYNAMIC EFFECTS IN OTHER OUTCOME VARIABLES	
			*---------------------------------------------------------------------------	
			
			sort  merchant_fuc Date
				
			gen Adoption_1=Adoption
			replace Adoption_1=0 if Adoption==1 & Adoption[_n-1]==0 & merchant_fuc==merchant_fuc[_n-1]
				
			gen Adoption_2=Adoption_1
			replace Adoption_2=0 if Adoption_1==1 & Adoption_1[_n-1]==0 & merchant_fuc==merchant_fuc[_n-1]
				
			gen Adoption_3=Adoption_2
			replace Adoption_3=0 if Adoption_2==1 & Adoption_2[_n-1]==0 & merchant_fuc==merchant_fuc[_n-1]
				
			gen Adoption_4=Adoption_3
			replace Adoption_4=0 if Adoption_3==1 & Adoption_3[_n-1]==0 & merchant_fuc==merchant_fuc[_n-1]
				
			gen Adoption_5=Adoption_4
			replace Adoption_5=0 if Adoption_4==1 & Adoption_4[_n-1]==0 & merchant_fuc==merchant_fuc[_n-1]
				
			gen Adoption_6=Adoption_5
			replace Adoption_6=0 if Adoption_5==1 & Adoption_5[_n-1]==0 & merchant_fuc==merchant_fuc[_n-1]
				
			gen Adoption_7=Adoption_6
			replace Adoption_7=0 if Adoption_6==1 & Adoption_6[_n-1]==0 & merchant_fuc==merchant_fuc[_n-1]
				
			gen temp_quarter_pre=1 if Adopter==1  
			gen temp_amount_quater_pre= temp_quarter_pre*TotalAmount
			bys merchant_fuc: egen temp_mean_quarter_pre=mean(temp_amount_quater_pre)
			bys merchant_fuc: gen temp_first=(_n==1)
							
			egen temp_group=group(merchant_category_id)  
			gen temp_threshold=.
			levelsof temp_group, local(levels) 
			foreach l of local levels { 
				sum temp_mean_quarter_pre if temp_group==`l' & temp_first==1 & Adopter==1,d
				local temp_t=r(p50)
				replace temp_threshold=`temp_t' if temp_group==`l'
				}
			
			gen temp_Big_size= (temp_mean_quarter_pre>=temp_threshold & Adopter==1)
			gen temp_Small_size= (temp_mean_quarter_pre<temp_threshold & Adopter==1)
			
			gen samplesmall=0
			replace samplesmall=1 if Adopter==0
			replace samplesmall=1 if temp_Small_size==1

			gen samplebig=0
			replace samplebig=1 if Adopter==0
			replace samplebig=1 if temp_Big_size==1

			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
														
			reghdfe D.(Log_TotalAmount Adoption) D.Age_* if samplesmall==1, absorb($Controls) vce(cluster merchant_fuc) 

			reghdfe D.(Log_TotalAmount Adoption Adoption_1 Adoption_2 Adoption_3 Adoption_4 Adoption_5 Adoption_6 Adoption_7)	D.Age_* if samplesmall==1, absorb($Controls) vce(cluster merchant_fuc)	

			cap drop res
			reghdfe D.Adoption IV_NonAcc_real_2 D.Age_* if samplesmall==1, absorb($Controls) vce(cluster merchant_fuc) residuals(resA)
				
			reghdfe D.(Log_TotalAmount Adoption) resA D.Age_* if samplesmall==1, absorb($Controls) vce(cluster  merchant_fuc) 

			reghdfe D.(Log_TotalAmount Adoption) D.Age_* if samplebig==1, absorb($Controls) vce(cluster merchant_fuc) 

			reghdfe D.(Log_TotalAmount Adoption Adoption_1 Adoption_2 Adoption_3 Adoption_4 Adoption_5 Adoption_6 Adoption_7)	D.Age_* if samplebig==1, absorb($Controls) vce(cluster merchant_fuc)	

			cap drop resA
			reghdfe D.Adoption IV_NonAcc_real_2 D.Age_* if samplebig==1, absorb($Controls) vce(cluster merchant_fuc) residuals(resB)
			
			reghdfe D.(Log_TotalAmount Adoption) resB D.Age_* if samplebig==1, absorb($Controls) vce(cluster  merchant_fuc) 
				
			
			*---------------------------------------------------------------------------	
			* TABLE B9: SEPARATING THE SAMPLE INTO LARGE AND SMALL ADOPTERS	
			*---------------------------------------------------------------------------	
					
			xtset merchant_fuc Date
			global Controls="i.Date#i.Zone#i.Sector" 
								
			gen Log_value_cust=log(TotalAmount/Customers)
									
			gen Log_trans_cust=log(Transactions/Customers)

			reghdfe D.(Log_Transactions Adoption Adoption_1 Adoption_2 Adoption_3 Adoption_4 Adoption_5 Adoption_6 Adoption_7) D.Age_*, absorb($Controls) vce(cluster merchant_fuc)	

			reghdfe D.(Log_Customers Adoption Adoption_1 Adoption_2 Adoption_3 Adoption_4 Adoption_5 Adoption_6 Adoption_7) D.Age_*, absorb($Controls) vce(cluster merchant_fuc)	

			reghdfe D.(Log_trans_cust Adoption Adoption_1 Adoption_2 Adoption_3 Adoption_4 Adoption_5 Adoption_6 Adoption_7) D.Age_*, absorb($Controls) vce(cluster merchant_fuc)

			reghdfe D.(Log_value_cust Adoption Adoption_1 Adoption_2 Adoption_3 Adoption_4 Adoption_5 Adoption_6 Adoption_7) D.Age_*, absorb($Controls) vce(cluster merchant_fuc)

			reghdfe D.(Log_AverageAmount Adoption Adoption_1 Adoption_2 Adoption_3 Adoption_4 Adoption_5 Adoption_6 Adoption_7) D.Age_*, absorb($Controls) vce(cluster merchant_fuc)

	
	clear			
			
			
	************* THE END *************
